package cn.chenc.framework.core.model.response;

import cn.chenc.framework.core.consts.HttpStatus;

/**
 * @Author secret
 * @Date 2021/2/26 19:56
 * @Version 1.0
 */
public class CustomCode implements ResultCode {

    /**
     * 操作是否成功
     */
    boolean success;
    /**
     * 错误代码
     */
    Integer code;
    /**
     * 提示信息
     */
    String message;

    public CustomCode(boolean success, Integer code, String message) {
        this.success=success;
        this.code=code;
        this.message=message;
    }

    @Override
    public boolean success() {
        return success;
    }

    @Override
    public int code() {
        return code;
    }

    @Override
    public String message() {
        return message;
    }

    public static ResultCode success(String message){
        return new CustomCode(true, HttpStatus.SUCCESS,message);
    }

    public static ResultCode error(String message){
        return new CustomCode(false,HttpStatus.ERROR,message);
    }

    public static ResultCode vo(int code,String message){
        return new CustomCode(false,code,message);
    }

}
